
Array.prototype._map = function(callback, context) {
    let arr = Array.prototype.slice.call(this);
    let res = this.reduce((acc, cur, index, src) => {
        let curRes = callback.call(context, cur, index, this, src)
        acc.push(curRes);
        return acc;
    }, [])
    return res;
}

// case
var a = [1, 2, 3]

// console.log(a.map((v, i, data) => {
console.log(a._map((v, i, data) => {
    console.log(v, i, data)
    return Math.pow(v, 2)
}))

// 1 0 [ 1, 2, 3 ]
// 2 1 [ 1, 2, 3 ]
// 3 2 [ 1, 2, 3 ]
// [ 1, 4, 9 ]